package com.xpengplayer.data;

import java.io.Serializable;
import java.util.Date;

/**
 * 播放历史记录模型类
 */
public class PlayHistory implements Serializable {
    private String videoPath;  // 视频文件路径
    private String videoTitle;  // 视频标题
    private long lastPlayTime;  // 上次播放时间戳
    private long playbackPosition;  // 上次播放位置（毫秒）
    private long duration;  // 视频总时长（毫秒）

    public PlayHistory(String videoPath, String videoTitle) {
        this.videoPath = videoPath;
        this.videoTitle = videoTitle;
        this.lastPlayTime = new Date().getTime();
        this.playbackPosition = 0;
        this.duration = 0;
    }

    public String getVideoPath() {
        return videoPath;
    }

    public void setVideoPath(String videoPath) {
        this.videoPath = videoPath;
    }

    public String getVideoTitle() {
        return videoTitle;
    }

    public void setVideoTitle(String videoTitle) {
        this.videoTitle = videoTitle;
    }

    public long getLastPlayTime() {
        return lastPlayTime;
    }

    public void setLastPlayTime(long lastPlayTime) {
        this.lastPlayTime = lastPlayTime;
    }

    public long getPlaybackPosition() {
        return playbackPosition;
    }

    public void setPlaybackPosition(long playbackPosition) {
        this.playbackPosition = playbackPosition;
    }

    public long getDuration() {
        return duration;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    /**
     * 更新播放时间和进度
     */
    public void updatePlaybackInfo(long position, long duration) {
        this.lastPlayTime = new Date().getTime();
        this.playbackPosition = position;
        this.duration = duration;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null || getClass() != obj.getClass()) return false;
        PlayHistory history = (PlayHistory) obj;
        return videoPath.equals(history.videoPath);
    }

    @Override
    public int hashCode() {
        return videoPath.hashCode();
    }
}